import 'package:flutter/material.dart';
// import 'package:sow_app_mock/sow_app_mock.dart';

import 'controller/state_feedback_controller.dart';
import 'controller/state_tag_novel_controller.dart';
import 'presenter/state_feedback_presenter.dart';
import 'util/share_preferences/preferences.dart';
import 'repository/ajax_rest_client.dart';
import 'controller/state_chapter_detail_controller.dart';
import 'controller/state_classify_controller.dart';
import 'controller/state_library_controller.dart';
import 'controller/state_novel_detail_controller.dart';
import 'controller/state_register_controller.dart';
import 'controller/state_search_controller.dart';
import 'controller/state_app_controller.dart';
import 'controller/state_home_controller.dart';
import 'controller/state_info_controller.dart';
import 'controller/state_login_controller.dart';
import 'controller/state_setting_controller.dart';

import 'presenter/state_tag_novel_presenter.dart';
import 'presenter/state_app_presenter.dart';
import 'presenter/state_chapter_detail_presenter.dart';
import 'presenter/state_classify_presenter.dart';
import 'presenter/state_home_presenter.dart';
import 'presenter/state_info_presenter.dart';
import 'presenter/state_library_presenter.dart';
import 'presenter/state_login_presenter.dart';
import 'presenter/state_novel_detail_presenter.dart';
import 'presenter/state_register_presenter.dart';
import 'presenter/state_search_presenter.dart';
import 'presenter/state_setting_presenter.dart';
import 'view/app.dart';

void main() {
  final pref = Preferences();
  final AjaxRestClient client = AjaxRestClient();
  // final MockRestClient client = MockRestClient();
  final presenter = StateAppPresenter();
  final chapterDetailPresenter = StateChapterDetailPresenter();
  final classifyPresenter = StateClassifyPresenter();
  final tagNovelPresenter = StateTagNovelPresenter();
  final homePresenter = StateHomePresenter();
  final infoPresenter = StateInfoPresenter();
  final libraryPresenter = StateLibraryPresenter();
  final loginPresenter = StateLoginPresenter();
  final novelDetailPresenter = StateNovelDetailPresenter();
  final registerPresenter = StateRegisterPresenter();
  final searchPresenter = StateSearchPresenter();
  final feedbackPresenter = StateFeedbackPresenter();
  final settingPresenter = StateSettingPresenter(client);

  loginPresenter.onLogout = () {
    presenter.currentToken = '';
    presenter.onComplete();
  };
  runApp(App(
    presenter: presenter,
    chapterDetailPresenter: chapterDetailPresenter,
    classifyPresenter: classifyPresenter,
    tagNovelPresenter: tagNovelPresenter,
    homePresenter: homePresenter,
    infoPresenter: infoPresenter,
    libraryPresenter: libraryPresenter,
    loginPresenter: loginPresenter,
    novelDetailPresenter: novelDetailPresenter,
    registerPresenter: registerPresenter,
    searchPresenter: searchPresenter,
    settingPresenter: settingPresenter,
    feedbackPresenter: feedbackPresenter,
    client: client,
    controller: StateAppController(presenter, client, pref),
    chapterDetailController:
        AjaxChapterDetailController(chapterDetailPresenter, client),
    classifyController: AjaxClassifyController(classifyPresenter, client),
    tagNovelController: AjaxTagNovelController(tagNovelPresenter, client),
    homeController: AjaxHomeController(homePresenter, client, pref),
    infoController: AjaxInfoController(infoPresenter, client, pref),
    libraryController: AjaxLibraryController(libraryPresenter, client),
    loginController: AjaxLoginController(loginPresenter, client, pref),
    novelDetailController:
        AjaxNovelDetailController(novelDetailPresenter, client, pref),
    settingController: AjaxSettingController(settingPresenter, client, pref),
    registerController: AjaxRegisterController(registerPresenter, client, pref),
    searchController: AjaxSearchController(searchPresenter, client, pref),
    feedbackController: AjaxFeedbackController(feedbackPresenter, client),
    // controller: MockAppController(presenter, client),
    // chapterDetailController:
    //     MockChapterDetailController(chapterDetailPresenter),
    // classifyController: MockClassifyController(classifyPresenter),
    // tagNovelController: MockTagNovelController(tagNovelPresenter),
    // homeController: MockHomeController(homePresenter, client),
    // infoController: MockInfoController(infoPresenter, client),
    // libraryController: MockLibraryController(libraryPresenter),
    // loginController: MockLoginController(loginPresenter, client),
    // novelDetailController: MockNovelDetailController(novelDetailPresenter),
    // settingController: MockSettingController(settingPresenter, client),
    // registerController: MockRegisterController(registerPresenter, client),
    // searchController: MockSearchController(searchPresenter),
  ));
}
